package com.xiangyueEducation.uploaderCloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiangyueEducation.uploaderCloud.mapper.UserMapper;
import com.xiangyueEducation.uploaderCloud.mapper.mapperUtil.UserMapperUtil;
import com.xiangyueEducation.uploaderCloud.pojo.entity.User;
import com.xiangyueEducation.uploaderCloud.service.InfoService;
import com.xiangyueEducation.uploaderCloud.utils.Result;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Service
public class InfoServiceImpl implements InfoService {

    @Autowired
    UserMapperUtil userMapperUtil;
    @Resource
    UserMapper userMapper;

    @Override
    public Result<?> getStuMainInfo(Long userId) {
        User user = userMapper.selectById(userId);
        return Result.ok(user);
    }

    @Override
    public Result<?> getStuAllMainInfo() {
        return Result.ok(userMapper.selectList(new QueryWrapper<>()));
    }

    @Override
    public Result<?> updateStuInfo(User user) {
        int i = userMapper.updateById(user);
        return Result.ok("修改成功");


    }

    @Override
    public Result<?> addStuInfo(User user) {
        userMapper.insert(user);
        return Result.ok("添加成功学生成功");
    }

    @Override
    public Result<?> getRoleId(Long userId) {
        User user = userMapper.selectById(userId);
        return Result.ok(user.getRoleId());
    }


}
